package com.dai.zhenfujin.my.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dai.zhenfujin.Constants.Constants;
import com.dai.zhenfujin.R;
import com.dai.zhenfujin.base.BaseActivity;
import com.dai.zhenfujin.bean.UserBean;
import com.dai.zhenfujin.http.CallBack;
import com.dai.zhenfujin.http.HttpClient;
import com.dai.zhenfujin.my.activity.wallet.AccountActivity;
import com.dai.zhenfujin.my.activity.wallet.TopUpActivity;
import com.dai.zhenfujin.utils.UIUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 钱包
 */
public class WalletActivity extends BaseActivity implements View.OnClickListener{
    private TextView tvName,tvPrice,wallet_price;
    private ImageView imageView;
    private RelativeLayout rlLooseChange,rlWechat,rlSafety,rlAccount;
    private UserBean userBean;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet);
        initView();
        initData();
        tvName.setText("钱包");
    }


    private void initView() {
        tvName = findViewById(R.id.title_textview);
        imageView = findViewById(R.id.title_imageview);
        wallet_price = findViewById(R.id.wallet_price);

        rlLooseChange = findViewById(R.id.wallet_loose_change);
//        rlWechat = findViewById(R.id.wallet_wechat);
        rlSafety = findViewById(R.id.wallet_safety);
        rlAccount = findViewById(R.id.wallet_account);
      //  refreshLayout = findViewById(R.id.refreshLayout);

        imageView.setOnClickListener(this);
        rlLooseChange.setOnClickListener(this);
//        rlWechat.setOnClickListener(this);
        rlSafety.setOnClickListener(this);
        rlAccount.setOnClickListener(this);

     //   onRefresh();
     //   initRefresh();
    }

    private void initRefresh() {
    }



    private void onRefresh() {

    }


    private void getWalletList(boolean b) {

    }

    private void initData() {
        List<String> path = new ArrayList<>();
        Map<String, Object> params = new HashMap<>();
        Map<String, Object> params2 = new HashMap<>();
        params.put("req_bd", params2);
        HttpClient.post(this, Constants.ACCOUNTINFO, params, new CallBack<UserBean>() {
            @Override
            public void onSuccess(UserBean resultBean) {
                userBean = resultBean;
                wallet_price.setText("￥" + UIUtils.getamount(resultBean.user_balance));
            }
        });
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.title_imageview://返回
                finish();
                break;
            case R.id.wallet_loose_change://零钱
//                Intent change = new Intent(this,LooseChangeActivity.class);
////                startActivity(change);
                Intent change = new Intent(this,TopUpActivity.class);
                change.putExtra("userBean",userBean);
                startActivity(change);
                break;
//            case R.id.wallet_wechat://微信支付
//                break;
            case R.id.wallet_safety://安全保障
                break;
            case R.id.wallet_account://账单
//                Intent intent = new Intent(this,AccountActivity.class);
//                startActivity(intent);
                Intent intent = new Intent(this,AccountActivity.class);
                startActivity(intent);
                break;
        }
    }
}
